package com.frame.exception
import org.apache.shiro.authz.UnauthenticatedException
import org.slf4j.Logger
import org.slf4j.LoggerFactory

import javax.ws.rs.core.Response
import javax.ws.rs.ext.ExceptionMapper
import javax.ws.rs.ext.Provider
/**
 * Created by three on 14-8-4.
 */
@Provider
class UnauthenticatedExceptionMapper implements ExceptionMapper<UnauthenticatedException> {

    private Logger log = LoggerFactory.getLogger(UnauthenticatedExceptionMapper.class);

    @Override
    Response toResponse(UnauthenticatedException exception) {
        log.info("权限认证错误", exception)
        return Response.status(Response.Status.UNAUTHORIZED).entity("你的权限有误，请联系管理员! "+exception.getMessage()).
                type("text/plain").build();
    }
}
